package com.fenghongzhang.day007;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.shuyu.gsyvideoplayer.GSYVideoManager;

import java.util.ArrayList;
import java.util.List;


/**
 * A simple {@link Fragment} subclass.
 */
public class ThreeFragment extends Fragment {
    private RecyclerView rv;
    private static final String TAG = "ThreeFragment";

    public ThreeFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.i(TAG, "onCreate: ");
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        Log.i(TAG, "onCreateView: ");
        View inflate = inflater.inflate(R.layout.fragment_three, container, false);
        rv = (RecyclerView) inflate.findViewById(R.id.rv);


        MyLinearManager myLinearManager = new MyLinearManager(getActivity());
        rv.setLayoutManager(myLinearManager);

        return inflate;
    }


    @Override
    public void onResume() {
        super.onResume();
        GSYVideoManager.onResume();
        Toast.makeText(getActivity(), "laile", Toast.LENGTH_SHORT).show();
        List<VideoBean> list = new ArrayList<>();
        for (int i = 0; i < TestVideoUrl.videoUrls.length; i++) {
            list.add(new VideoBean());
        }
        MyRVAdapter myRVAdapter = new MyRVAdapter(R.layout.rv_layout, list);
        rv.setAdapter(myRVAdapter);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        Log.i(TAG, "onDestroyView: ");
    }



    @Override
    public void onPause() {
        super.onPause();
        GSYVideoManager.onPause();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        GSYVideoManager.releaseAllVideos();
        Log.i(TAG, "onDestroy: ");
    }
}
